<?php

namespace App\Modules\User\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Modules\User\Models\User;
use App\Modules\User\Http\Requests\UserCreateRequest;
use App\Modules\User\Http\Requests\UserUpdateRequest;
use App\Modules\User\Http\Resources\UserResource;
use App\Http\Controllers\Controller;

class UserController extends Controller
{

    /**
     * @var Laoha\Modules
     */
    protected $module_slug = "user";

    /**
     * @var Laoha\Modules
     */
    protected $module;

    /**
     * @param Laoha\Modules $module
     */
    protected function module()
    {        
        $data = User::paginate(10);
        $data = UserResource::collection($data);
        
        $_ext['module'] = get_module($this->module_slug);
        $_ext['status'] = 1;
        $_ext['message'] = '';
        $_ext['code'] = 200;
        $_ext['url'] = url()->current();
        
        return $data->additional($_ext); 
    }
    
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return $this->module();
	//
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \App\Modules\User\Http\Requests\UserCreateRequest  $request
     * @return \Illuminate\Http\Response
     */
    public function store(UserCreateRequest $request)
    {
       
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $data = User::find($id);
        $data = new UserResource($data);
        
        $_ext['module'] = get_module($this->module_slug);
        $_ext['status'] = 1;
        $_ext['message'] = '';
        $_ext['code'] = 200;
        $_ext['url'] = url()->current();
        
        return $data->additional($_ext); 
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \App\Modules\User\Http\Requests\UserUpdateRequest  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(UserUpdateRequest $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
